package com.itheima;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CollectionsDemo {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        Collections.addAll(list,"zhangsan","lisi","wangwu");
        list.forEach(System.out::println);
        System.out.println("-------------------");
        Collections.shuffle(list);
        list.forEach(System.out::println);
        test1();
    }

    public static void test1(){
        List<Integer> list=new ArrayList<>();
        Collections.addAll(list,5,1,2,3);
        Collections.sort(list);
        list.forEach(System.out::println);
        System.out.println("-------------倒序排序-------------");
        Collections.sort(list,((o1, o2) -> {
            return o2-o1;
        }));
        list.forEach(System.out::println);
        System.out.println("--------------将学生按年龄升序排序---------");
        List<Student> list1=new ArrayList<>();
//        list1.add(new Student("zhangsan",13));
//        list1.add(new Student("zhangsan",13));
//        list1.add(new Student("lisi",20));
//        list1.add(new Student("wangwu",18));
//        list1.forEach(System.out::println);
//        System.out.println("-----------------------");
//        System.out.println(Collections.frequency(list1,new Student("zhangsan",13)));
//        System.out.println("------------------------");
        //同步
        Collections.synchronizedList(list);

    }
}
